package com.yycx.module.bus.provider.controller;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.base.utils.FlymeUtils;
import com.yycx.module.bus.provider.service.BusFinanceService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yycx.common.mybatis.model.*;

import java.util.List;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RestController;
import com.yycx.common.springmvc.base.BaseController;
import com.yycx.module.bus.client.entity.BusFinanceDetails;
import com.yycx.module.bus.provider.service.BusFinanceDetailsService;


/**
 * 对账明细控制器
 *
 * @author flyme
 * @date 2021-01-10
 */
@RestController
@RequestMapping("/bus/bfd/")
public class BusFinanceDetailsController extends BaseController<BusFinanceDetailsService, BusFinanceDetails> {

    @Autowired
    private BusFinanceService busFinanceService;

    @ApiOperation(value = "对账明细-分页列表", notes = "对账明细分页列表")
    @GetMapping(value = "page")
    public ResultBody pageList(@RequestParam(required = false) Map params) {
        return bizService.pageList(params);
    }

    @ApiOperation(value = "对账明细-列表", notes = "对账明细列表")
    @GetMapping(value = "list")
    public ResultBody list(@RequestParam(required = false) Long financeId) {
        Map<String, Object> map = (Map<String, Object>) redisUtils.get("DZ:" + financeId);
        if (FlymeUtils.isEmpty(map)) {
            map = busFinanceService.initData(financeId);
        }
        EntityMap result = new EntityMap();
        Object orderDetailList = map.get("orderDetailList");
        Object lastReturnList = map.get("lastReturnList");
        Object lastSettleList = map.get("lastSettleList");
        result.put("orderDetailList", orderDetailList);
        result.put("lastReturnList", lastReturnList);
        result.put("lastSettleList", lastSettleList);
        return ResultBody.ok(result);
    }

    @ApiOperation(value = "对账明细-添加", notes = "添加对账明细")
    @PostMapping(value = "save")
    public ResultBody save(@RequestParam(required = false) Map params) {
        return bizService.add(params);
    }

    @ApiOperation(value = "对账明细-更新", notes = "更新对账明细")
    @PostMapping(value = "update")
    public ResultBody update(@RequestParam(required = false) Map params) {
        return bizService.edit(params);
    }

    @ApiOperation(value = "对账明细-删除", notes = "删除对账明细")
    @PostMapping(value = "remove")
    public ResultBody remove(@RequestParam(required = false) Map params) {
        return bizService.delete(params);
    }


    @ApiOperation(value = "对账明细-详情", notes = "对账明细详情")
    @GetMapping(value = "get")
    public ResultBody get(@RequestParam(required = false) Map params) {
        return bizService.get(params);
    }

}
